fix(interface): silence registry-default deprecation when library auto-fills it#655
Conversation
…o-fills it The ``ModelProviderRegistry.default is deprecated`` warning added in #594 fires for every fresh-install ``DataDesigner()`` construction, even when the user wrote ``default=`` nowhere — neither in YAML, nor in Python, nor in any ``ModelConfig``. Root cause: ``resolve_model_provider_registry`` synthesises ``default=providers[0].name`` for the multi-provider case to satisfy ``check_implicit_default``. The auto-seeded ``~/.data-designer/model_providers.yaml`` ships three providers and no ``default:`` key, so this path is hit on every bare ``DataDesigner()`` call. ``_warn_on_explicit_default`` then attributes the warning to the user's ``DataDesigner()`` line, with a remediation message ("Specify provider= explicitly on each ModelConfig") that doesn't even apply when the user hasn't built a ``ModelConfig`` (e.g. a UUID-only sampler config with the GitHub plugin). Fix: broaden the existing warning suppression in ``DataDesigner.__init__`` to also cover the ``model_providers is None`` case. The user is opting into all defaults — the library is the one filling ``default=``, so the deprecation nudge is misdirected. Users who hand-construct a multi-provider list in Python still see the warning (they wrote the multi-provider intent themselves), and direct ``ModelProviderRegistry(default="x")`` always warns — those are the entry points #589 actually targets. New regression test pins the bare-``DataDesigner()`` quiet path so a future tightening of the suppression can't silently re-introduce the spurious warning. Refs #589, follow-up to #594. Signed-off-by: Nabin Mulepati <nmulepati@nvidia.com>
SummaryPR #655 fixes a spurious The fix broadens the existing
A new regression test ( FindingsCorrectness — looks good
Code quality
Test coverage — strong
Risks / blast radius — minimal
Security — n/aNo auth, secret-handling, input-validation, or network surface touched. The test stubs use fake endpoints and Performance — n/aNo hot-path or import-time impact; the only added work is one boolean evaluation in Minor observations (non-blocking)
VerdictApprove / LGTM (non-binding — automated review). This is a tight, well-scoped fix for a high-visibility paper-cut (every fresh-install user hits this). The code change is one expression; the comment explaining why is appropriately defensive given this is the second iteration in this spot. The new regression test pins both the warning suppression and the first-wins behavioural contract that motivated #588, so the next refactor can't silently regress either property. The PR description, behaviour matrix, and test cross-references are exemplary. No changes requested. |
Greptile SummaryThis PR fixes a spurious
|
| Filename | Overview |
|---|---|
| packages/data-designer/src/data_designer/interface/data_designer.py | Widens the warning suppression guard to cover the model_providers is None path; logic is correct and targeted to only the ModelProviderRegistry.default is deprecated message. |
| packages/data-designer/tests/interface/test_data_designer.py | Adds a well-structured regression test that patches both YAML helpers, asserts no spurious deprecation warning, and pins first-wins provider resolution. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["DataDesigner.__init__(model_providers=?)"] --> B{model_providers is None?}
B -- Yes --> C["_resolve_model_providers(None)\n→ calls get_default_providers()"]
B -- No --> D["_resolve_model_providers(model_providers)\ndefault_provider_name = None"]
C --> E["get_default_provider_name()"]
E -- "returns None\n(no YAML default:)" --> F["default_provider_name = None"]
E -- "returns 'name'\n(YAML default: key set)" --> G["default_provider_name = 'name'\n(YAML DeprecationWarning already fired)"]
F --> H["library_synthesised_default = True\n(model_providers is None)"]
G --> H
D --> I["library_synthesised_default = False"]
H --> J["warnings.filterwarnings ignore\n'ModelProviderRegistry.default is deprecated'"]
J --> K["resolve_model_provider_registry(providers, default_provider_name)"]
I --> K
K --> L{Multi-provider\n& no explicit default?}
L -- Yes --> M["synthesise default=providers[0].name\n_warn_on_explicit_default fires"]
L -- No --> N["Registry built normally"]
M -- suppressed if library_synthesised_default --> O["✅ Quiet (library filled it in)"]
M -- not suppressed if user-supplied --> P["⚠️ DeprecationWarning visible to user"]
N --> Q["✅ Registry ready"]
Reviews (1): Last reviewed commit: "fix(interface): silence registry-default..." | Re-trigger Greptile
johnnygreco
left a comment
There was a problem hiding this comment.
Nice work on this one, @nabinchha, this is a tight fix with the right regression coverage.
Summary
This PR suppresses the registry-level default-provider deprecation warning only when DataDesigner itself is filling the registry default from YAML-backed construction, while preserving warnings for user-supplied multi-provider lists and direct ModelProviderRegistry(default=...) usage. The implementation matches the stated intent in the PR description.
Findings
No findings.
What Looks Good
- The suppression is scoped narrowly around
resolve_model_provider_registry, so unrelated deprecation warnings still surface normally. - The new regression test captures both parts of the desired behavior: no spurious warning for bare
DataDesigner()and first-provider fallback still resolving correctly. - Existing tests already pin the complementary user-supplied and YAML-
default:warning paths, which makes this small behavior change feel well boxed in.
Verdict
Ship it: ready to merge as-is.
This review was generated by an AI assistant.
📋 Summary
Fix for the spurious
ModelProviderRegistry.default is deprecatedwarning that fires for every fresh-installDataDesigner()construction, even when the user wrotedefault=nowhere — neither in YAML, nor in Python, nor in anyModelConfig. Reported by @johnny-greco in Slack while testing the GitHub plugin and the tutorials.The reporter's snippet — pure
DataDesignerConfigBuilder+ a UUID sampler + bareDataDesigner().preview(...), with zeroModelConfigs anywhere — surfaces the warning attributed to theDataDesigner()line, with a remediation message ("Specifyprovider=explicitly on eachModelConfig") that doesn't apply.🔗 Related Issue
Refs #589, follow-up to #594.
🔍 Root cause
resolve_model_provider_registrysynthesisesdefault=providers[0].namefor the multi-provider case to satisfycheck_implicit_default. The auto-seeded~/.data-designer/model_providers.yamlships three providers and nodefault:key, so this path is hit on every bareDataDesigner()call._warn_on_explicit_defaultthen attributes the warning to the user'sDataDesigner()line — but the user never opted into the deprecated registry-level default; the library filled it in.The existing suppression in
DataDesigner.__init__only covered the YAML-default-fallback case (whereget_default_provider_name()already emitted the YAML deprecation). The library-auto-fill case was unsuppressed.🔄 Changes
🔧 Changed
DataDesigner.__init__— broaden the existingwarnings.catch_warnings()suppression so it also coversmodel_providers is None(the "we're about to load the YAML and synthesise a default" case). Updated the comment to spell out both branches.ModelProviderRegistry(default="x")always warns. Those are the entry points refactor: deprecate implicit default model provider routing #589 actually targets.✨ Added
test_init_no_user_providers_no_yaml_default_stays_quiet— pins the bare-DataDesigner()quiet path against multi-provider YAML with nodefault:key, plus a behavioral pin that first-wins still resolves correctly. A future tightening of the suppression can't silently re-introduce the spurious warning.🧪 Behavior matrix
DataDesigner()(Slack repro + tutorial line 46)DataDesigner(model_providers=[single])DataDesigner(model_providers=[multi])user-suppliedModelProviderRegistry(default="x")default:key set✅ Checklist
make check-all-fixcleantest_data_designer.py,test_model_provider.py,test_models.pyprovider=explicitly — PR feat(models): deprecate implicit default provider routing #594 covered them, no further example updates needed